package com.example.basic.core.foreignData;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.example.basic.core.result.ResultCode;
import io.swagger.annotations.ApiModel;

import java.io.Serializable;
import java.util.Date;

@ApiModel(description = "对外接口出参模型")
public class ForeignDataResult<T> implements Serializable {

    @JSONField(ordinal = 1)
    private int code;
    @JSONField(ordinal = 2)
    private String message;
    @JSONField(ordinal = 4)
    private T data;

    public ForeignDataResult<T> setCode(ResultCode resultCode) {
        this.code = resultCode.code;
        return this;
    }

    public int getCode() {
        return code;
    }

    public ForeignDataResult<T> setCode(int code) {
        this.code = code;
        return this;
    }

    public String getMessage() {
        return message;
    }

    public ForeignDataResult<T> setMessage(String message) {
        this.message = message;
        return this;
    }


    public Object getData() {
        return data;
    }

    public ForeignDataResult<T> setData(T data) {
        this.data = data;
        return this;
    }

    public ForeignDataResult(T data) {
        super();
        this.data = data;
    }

    public ForeignDataResult() {
        super();
        this.data = null;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }
}
